home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / include / dvfds.h < prev    next >
C/C++ Source or Header  |  1997-05-08  |  7KB  |  222 lines

  1. /*
  2. |    file name -- dvfds.h
  3. |===================================================================
  4. |
  5. |              copyright (c) 1989-91, V.I. Corporation
  6. |
  7. |    dvfds.h -- Includes useful in function Data source modules
  8. |
  9. |    alan c morse      24 apr 89    initial release
  10. |
  11. |      charlie hileman    12 dec 90   expanded function types
  12. |      charlie hileman    15 jan 91   added structure for optional args
  13. |      alan morse    15 mar 91   modified macro to make more portable
  14. |      Len Bertelli     28 sep 94   changed V_FDS_FCN_WRITE comments
  15. |
  16. |===================================================================
  17. |
  18. |    include-file description/function:
  19. |    This contains defines, macros, and data structures
  20. |    for use in modules that implement function data sources.
  21. |
  22. |===================================================================
  23. */
  24.  
  25. #ifndef V_DVFDS_INCLUDED
  26. #define V_DVFDS_INCLUDED
  27.  
  28. #include "std.h"
  29. #include "dvstd.h"
  30. #include "VOstd.h"
  31.  
  32. /* function used when V_FDS_DESC or V_FDS_FCN_DESC is missing */
  33. #define V_FDS_DEFAULT_NAME Mdefaultfdsfcn
  34. LONG V_FDS_DEFAULT_NAME();
  35.  
  36. /* limit for default function arguments */
  37. #define V_FDS_MAX_ARGS    10
  38.  
  39. /* defines using the types below - start, end, and max of types */
  40. #define V_FDS_FCN_START     V_FDS_FCN_DS_START
  41. #define V_FDS_FCN_END          V_FDS_FCN_DSV_END
  42. #define V_FDS_FCN_MAX_TYPES    V_FDS_FCN_DSV_END
  43.  
  44. /* Function types for a function descriptor set -
  45.      These enums are used to directly reference function tables.  They are
  46.      split up into two groups: DS and DSV function types. Unused enums are
  47.      added before the DS and DSV ends, allowing new types to be easily
  48.      added and tested (replace unused enum with new type for testing,
  49.      add back unused enum when checking the file in).
  50.  
  51.      To add a new type and have its function arguments saved and
  52.      restored, you must edit "Mfdsutils.c" and add the type to the
  53.      fixed-index table.  If deleting a type, you may also have to edit
  54.      this table (see the comments in the file).
  55. */
  56. typedef enum
  57.   {
  58.   /* *** Function types for data sources *** */
  59.   V_FDS_FCN_DS_START = 0,
  60.  
  61.   /* mandatory functions for all FDSets */
  62.   V_FDS_FCN_OPEN,
  63.   V_FDS_FCN_READ,
  64.   V_FDS_FCN_CLOSE,
  65.  
  66.   /* optional create, destroy, save, and restore functions */
  67.   V_FDS_FCN_DS_CREATE,
  68.   V_FDS_FCN_DS_DESTROY,
  69.   V_FDS_FCN_DS_SAVE,
  70.   V_FDS_FCN_DS_RESTORE,
  71.   V_FDS_FCN_WRITE,
  72.  
  73.   /* --> place all new DATA SOURCE types ABOVE this line <-- */
  74.   V_FDS_FCN_DS_X1, V_FDS_FCN_DS_X2, V_FDS_FCN_DS_X3,
  75.   V_FDS_FCN_DS_END,
  76.  
  77.  
  78.   /* *** Function types for ds VARIABLES *** */
  79.   V_FDS_FCN_DSV_START,
  80.  
  81.   /* mandatory functions for all FDSets */
  82.   V_FDS_FCN_SELECT,
  83.  
  84.   /* optional create and destroy functions */
  85.   V_FDS_FCN_DSV_CREATE,
  86.   V_FDS_FCN_DSV_DESTROY,
  87.  
  88.   /* write out selectively*/
  89.   V_FDS_FCN_SELECT_WRITE,
  90.  
  91.   /* --> place all new ds VARIABLE types ABOVE this line <-- */
  92.   V_FDS_FCN_DSV_X1, V_FDS_FCN_DSV_X2, V_FDS_FCN_DSV_X3,
  93.   V_FDS_FCN_DSV_END
  94.  
  95.   } V_FDS_FCN_ENUM;
  96.  
  97. /* argument value types */
  98. typedef enum
  99.   {
  100.   V_FDS_ARG_LONG,
  101.   V_FDS_ARG_DOUBLE,
  102.   V_FDS_ARG_TEXT,
  103.   V_FDS_ARG_DSV
  104.   } V_FDS_ARG_ENUM;
  105.  
  106.  
  107. /* argument block to declare default args - union cannot be casted */
  108. typedef struct
  109.   {
  110.   char *name;
  111.   V_FDS_ARG_ENUM type;
  112.   LONG l_val;
  113.   double d_val;
  114.   char *t_val;
  115.   } V_FDS_ARG_DECL;
  116.  
  117. /* argument block used to pass optional args to functions */
  118. typedef struct
  119.   {
  120.   int type;      /* V_NULL_TYPE, V_T_TYPE, V_L_TYPE, V_D_TYPE or V_DSV_TYPE */
  121.   ANYTYPE value;  /* union holds all possible values */
  122.   } V_FDS_OPT_ARG;
  123.  
  124.  
  125. /* structure used to declare a FDSet function */
  126. typedef struct
  127.   {
  128.   V_FDS_FCN_ENUM fcn_type;             /* type of function */
  129.   ADDRESS (*fcn)();                /* function pointer */
  130.   char *fcn_desc;                /* function description */
  131.   V_FDS_ARG_DECL def_args[V_FDS_MAX_ARGS];    /* default arguments */
  132.   } V_FDS_FCN_DESC;
  133.  
  134.  
  135. /* complete FDSet structure: a null-terminated array of V_FDS_FCN_DESC's */
  136. typedef V_FDS_FCN_DESC *(V_FDS_TABLE[]);
  137.  
  138. /* type used to pass FDSets around */
  139. typedef V_FDS_FCN_DESC **V_FDS_DESC;
  140.  
  141.  
  142. /* defines to declare arguments */
  143. #define V_FDS_LONG_ARG_DECL( name, value )   { name, V_FDS_ARG_LONG, value },
  144. #define V_FDS_DOUBLE_ARG_DECL( name, value ) { name, V_FDS_ARG_DOUBLE,0,value},
  145. #define V_FDS_TEXT_ARG_DECL( name, value )   {name,V_FDS_ARG_TEXT,0,0.0,value},
  146. #define V_FDS_DSVAR_ARG_DECL( name )          { name, V_FDS_ARG_DSV },
  147.  
  148.  
  149. /* generic define for declaring all FDSet functions */
  150. /* Needs to be fully bracketed, with at least one entry */
  151. /* (null entry at the end) to be portable. */
  152. #define V_FDS_FCN_DECL( fcn_type, desc_name, fcn, fcn_desc ) \
  153. LOCAL V_FDS_FCN_DESC desc_name = \
  154.   { \
  155.   fcn_type, (ADDRESS (*)())fcn, (char *)fcn_desc, \
  156.     {
  157.  
  158. #define V_FDS_END_FCN_DECL \
  159.       { (char*)0, 0 } /* Need at least one entry */ \
  160.     } \
  161.   };
  162.  
  163.  
  164. /* used to add defined function declarations to FDset */
  165. #define V_FDS_FCN_DEFINED( descname ) &descname,
  166.  
  167. #define V_FDS_NULL_DECL(name) \
  168. V_FDS_DESC name V_P_( (void) ); \
  169. V_FDS_DESC name() { return (V_FDS_DESC)NULL; } 
  170.  
  171. #define V_FDS_START_DECL(name) \
  172.      V_FDS_DESC name V_P_( (void) ); \
  173.      LOCAL V_FDS_DESC query_fds_table V_P_( (void) ); \
  174.      \
  175.      V_FDS_DESC name() { return query_fds_table(); } \
  176.      \
  177.      LOCAL V_FDS_TABLE L_fdstable = \
  178.  
  179. #define V_FDS_END_DECL \
  180.     (V_FDS_FCN_DESC*)NULL \
  181.  }; \
  182. \
  183. LOCAL V_FDS_DESC query_fds_table() { return L_fdstable; }
  184.  
  185.  
  186. /* ==================================================================
  187.   The defines below are for pre-9.0 compatibility. If compiling a
  188.   Function Descriptor Set with pre-9.0 defines, set "V_8TO9_COMPATIBILITY"
  189.   before including this file */
  190.  
  191. #ifdef V_8TO9_COMPATIBILITY
  192.  
  193. #define LONG_ARG_DECL         V_FDS_LONG_ARG_DECL
  194. #define DOUBLE_ARG_DECL     V_FDS_DOUBLE_ARG_DECL
  195. #define TEXT_ARG_DECL         V_FDS_TEXT_ARG_DECL
  196. #define DSVAR_ARG_DECL         V_FDS_DSVAR_ARG_DECL
  197.  
  198. #define INIT_FCN_DECL( dscname, fcn, name ) \
  199.     V_FDS_FCN_DECL( V_FDS_FCN_OPEN, dscname, fcn, name )
  200.  
  201. #define READ_FCN_DECL( dscname, fcn, name ) \
  202.     V_FDS_FCN_DECL( V_FDS_FCN_READ, dscname, fcn, name )
  203.  
  204. #define TERM_FCN_DECL( dscname, fcn, name ) \
  205.     V_FDS_FCN_DECL( V_FDS_FCN_CLOSE, dscname, fcn, name )
  206.  
  207. #define SELECT_FCN_DECL( dscname, fcn, name ) \
  208.     V_FDS_FCN_DECL( V_FDS_FCN_SELECT, dscname, fcn, name )
  209.  
  210. #define FCN_DECL        V_FDS_FCN_DEFINED
  211.  
  212. #define END_FCN_DECL        V_FDS_END_FCN_DECL
  213.  
  214. #define START_FDS_DECL         V_FDS_START_DECL
  215. #define END_FDS_DECL         V_FDS_END_DECL
  216.  
  217. #endif /* V_8TO9_COMPATIBILITY */
  218.  
  219.  
  220. #endif /* V_DVFDS_INCLUDED */
  221.